package com.recruit.server.controller;

import com.recruit.server.common.AccessAble;
import com.recruit.server.common.HeaderInfo;
import com.recruit.server.request.product.ListProductRequest;
import com.recruit.server.request.product.ProductDetailRequest;
import com.recruit.server.response.product.ListProductResponse;
import com.recruit.server.response.product.ProductDetailResponse;
import com.recruit.server.service.IProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/product")
public class ProductController {

    @Autowired
    private IProductService iProductService;

    @AccessAble
    @PostMapping("/list")
    public ListProductResponse list(@Validated @RequestBody ListProductRequest request, HeaderInfo headerInfo) {
        return iProductService.list(request, headerInfo);
    }

    @AccessAble
    @PostMapping("/detail")
    public ProductDetailResponse detail(@Validated @RequestBody ProductDetailRequest request, HeaderInfo headerInfo) {
        return iProductService.detail(request, headerInfo);
    }
}
